home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / updateSoundMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.7 KB  |  169 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.  
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  18 Nov 1996
  22. //
  23. //  Author: hmbw
  24. //
  25. // Procs: setSoundDisplay, updateSoundMenu
  26. //
  27. //  Description:
  28. //      Setup the menu for which sound to display by
  29. //    building up a list of audio nodes to choose from.
  30. //    Audio nodes can be created through File->import of
  31. //    a sound file.
  32. //
  33. global proc setSoundDisplay( string $node, int $state )
  34. {
  35.     global string $gPlayBackSlider;
  36.     timeControl -e -ds $state -s $node $gPlayBackSlider;
  37.  
  38.     // If we are in playback, then we have to update the sound that 
  39.     // is playing
  40.     //
  41.     if ( `play -query -state` ) {
  42.         $direction = `play -query -forward`;
  43.         if ( $state ) {
  44.             play -sound $node -forward $direction;
  45.         } else {
  46.             play -forward $direction;
  47.         }
  48.     }
  49. }
  50.  
  51. global proc updateSoundMenu( string $args[] )
  52. //
  53. // Description:
  54. //    $menu:  the name of the menu to build with
  55. //    entries for all the sound nodes.  
  56. //    
  57. //    $useRadio: Are all the sound node entries are to presented
  58. //    as a collection of radio buttons?  Yes, if $useRadio is true.
  59. //    $useRadio also provides an "off" button whose cmd can
  60. //    be set with $radioOffCmd.
  61. //    
  62. //    $cmd: the command to execute when an individual
  63. //    menu item is selected from the sound menu.  The name
  64. //    of the selected entry's sound node will be appended to
  65. //    the string passed in in $cmd.
  66. //    
  67. //    $annotation: the menu annotation displayed for the 
  68. //    menu entry.  The name of the entry's sound node is
  69. //    appended to the given $annotation.
  70. //    
  71. //    $radioOffCmd: When $useRadio is true, there is an "Off"
  72. //    button in the radio collection.  Use $radioOffCmd to supply
  73. //    the command executed when the "Off" radio is selected.
  74. //    
  75. //    $optionCmd: the command executed when an entry's
  76. //    option box is selected.  The name of the selected entry
  77. //    will be appended to the string passed in in $optionCmd.
  78. //    
  79. //    If the menu items should have no option boxes, pass
  80. //    in a null $optionCmd.
  81. //    
  82. {
  83.     string  $parent         = `setParent -m -q`;
  84.  
  85.     // Extract the variables we need from the string array.
  86.     //
  87.     string     $mySoundMenu    = $args[0];
  88.     int     $useRadio         = $args[1];
  89.     string     $cmd             = $args[2];
  90.     string     $annotation        = $args[3];
  91.     string     $radioOffCmd    = $args[4];
  92.     string     $optionCmd         = $args[5];
  93.  
  94.     global string $gPlayBackSlider;
  95.  
  96.     setParent -m $mySoundMenu;
  97.  
  98.     string $soundNodes[] = `ls -type audio`;
  99.     string $current = `timeControl -q -s $gPlayBackSlider`;
  100.  
  101.     // Get rid of previous contents
  102.     //
  103.     menu -e -deleteAllItems $mySoundMenu;
  104.  
  105.     //    Check to see if there's sound in the system,
  106.     //    and setup the menu entries appropriately
  107.     //
  108.     string $sound[] = `ls -type audio`;
  109.  
  110.     if( `size( $sound )` == 0 ) {
  111.         //
  112.         //    There's no sound - inform the user
  113.         //
  114.         menuItem -l "No sounds available" -enable false;
  115.     } else {
  116.         // Here's the Off entry
  117.         //
  118.         if( $useRadio && ( size( $radioOffCmd ) > 0 ) ) {
  119.             radioMenuItemCollection;
  120.             menuItem -rb 1 -l "Off" -c $radioOffCmd;
  121.         }
  122.     
  123.         // One entry for each sound node we found
  124.         //
  125.         for( $node in $soundNodes ) {
  126.             string $cmdString = substitute( "%s", $cmd, $node );
  127.             string $menuItemName = ($node + "Item");
  128.  
  129.             if( $useRadio ) {
  130.                 menuItem -rb 0 $menuItemName;
  131.             } else {
  132.                 menuItem $menuItemName;
  133.             }
  134.  
  135.             menuItem -e 
  136.                 -echoCommand on
  137.                 -label $node 
  138.                 -command $cmdString 
  139.                 -annotation ( substitute( "%s", $annotation, $node ) )
  140.                 $menuItemName;
  141.  
  142.             int $useOptionBox = (size( $optionCmd ) > 0);
  143.  
  144.             if( $useOptionBox ) {
  145.                 string $optionCmdString = substitute("%s", $optionCmd, $node);
  146. ;
  147.                 menuItem -enableCommandRepeat false -optionBox true
  148.                     -l (  $node + " Option Box" )
  149.                     -c $optionCmdString
  150.                     ($node+"Dialogitem");
  151.             }
  152.  
  153.             if( $useRadio && ( $node == $current ) ) {
  154.                 menuItem -e -rb 1 $menuItemName;
  155.             } 
  156.  
  157.         }
  158.     }
  159.  
  160.     if( $parent != "NONE" ) {
  161.         setParent -m $parent;
  162.     }
  163. }
  164.  
  165.  
  166.  
  167.  
  168.  
  169.